go to previous page   go to home page   go to next page

Answer:

No.


Searching a List

Often you need to search a list for a particular item. Here is a start of a longer example program:

class SearchTester
{
  public static void main ( String[] args )
  {
    final int theSize = 20 ;

    String[] strArray = new String[ theSize ] ;  

    strArray[0] = "Boston" ;
    strArray[1] = "Albany" ;
    strArray[2] = "Detroit" ;
    strArray[3] = "Phoenix" ;
    strArray[4] = "Peoria" ;
    strArray[6] = "Albany" ;
    strArray[7] = "Houston" ;
    strArray[8] = "Hartford" ;

    // print out only those cells with data
    for (int j=0; j  < strArray.length; j++ )
      if ( strArray[j] != null )
        System.out.println( strArray[j] );
  }
}

QUESTION 14:

Is "Peoria" in the list?